import fs from 'fs-extra'
import path from 'path'
import { getCurrentDirPath } from './common';

interface ILang {
    create: {
        description: string;
        options: {
            template: 'vue' | 'react';
        };
    };
}

export default () => {
    // 获取当前语言环境，如果是浏览器环境可以直接通过navigator.language获取
    const locale = Intl.DateTimeFormat().resolvedOptions().locale
    
    const localePath = path.join(getCurrentDirPath(), `/locale/${locale}.json`)
    const defaultPath = path.join(getCurrentDirPath(), `/locale/en-US.json`)
    const lang = fs.existsSync(localePath) ? fs.readJsonSync(localePath): fs.readJsonSync(defaultPath)

    return lang
}